# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=XML-LibXML
pkgname=perl-${_realname}
pkgver=2.0206
pkgrel=1
pkgdesc="Interface to the libxml library"
arch=('i686' 'x86_64')
license=('GPL' 'PerlArtistic')
url="https://search.cpan.org/dist/XML-LibXML"
groups=('perl-modules')
depends=('perl' 'perl-Alien-Libxml2' 'perl-XML-SAX' 'perl-XML-NamespaceSupport')
#checkdepends=('perl-Test-Pod' 'perl-Test-LeakTrace' 'perl-CPAN-Changes' 'perl-URI')
makedepends=('perl-devel' 'libxml2-devel' 'perl-Path-Tiny')
#replaces=('perlxml')
#provides=("perlxml=${pkgver}")
install=perl-xml-libxml.install
options=('!emptydirs')
source=("https://www.cpan.org/authors/id/S/SH/SHLOMIF/${_realname}-${pkgver}.tar.gz"
        'XML-LibXML-2.0200.patch')
sha256sums=('010ba395c38711f9c233ee23d0b0b18b761e6d99a762125f7e6180d068851619'
            'ea1e1f58f33681dc0206c4fa868cc191efeb91facaa88631bc79c73e910cf745')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/XML-LibXML-2.0200.patch
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  # install module in vendor directories.
  perl Makefile.PL INSTALLDIRS=vendor
  make
}

check() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make test
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make install DESTDIR="${pkgdir}"

  # remove perllocal.pod and .packlist.
  find "${pkgdir}" -name perllocal.pod -delete
  find "${pkgdir}" -name .packlist -delete

  # fix permissions
  find ${pkgdir}/usr -type f -name *.dll | xargs chmod 0755
}
